// wxWidgets "Hello World" Program

// For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h>
#include <wx/display.h>

#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif

#include "Win_Main.h"
#include <wx/artprov.h>

class MyApp : public wxApp
{
public:
    virtual bool OnInit();
    virtual int OnExit();
};

wxIMPLEMENT_APP(MyApp);

bool MyApp::OnInit()
{
    wxDisplay screen;
#ifdef _WIN32
#ifdef _DEBUG
    AllocConsole();
    SetConsoleOutputCP(CP_UTF8);
    freopen("CONOUT$", "w", stdout);
    freopen("CONOUT$", "w", stderr);
#endif
#endif
    // 可选：设置应用程序的外观模式,wxWidgets 3.3.0 及更高版本支持
    SetAppearance(Appearance::System);
    // SetAppearance(Appearance::Dark);
    // SetAppearance(Appearance::Light);

    wxRect screenRect = screen.GetClientArea(); // 获取主屏幕的客户区域大小
    int screenWidth = screenRect.GetWidth() * 0.4;
    int screenHeight = screenRect.GetHeight() * 0.4;
    MyFrame *frame = new MyFrame();
    frame->SetSize(screenWidth,screenHeight);
    frame->SetIcon(wxArtProvider::GetIcon(wxART_WX_LOGO));
    frame->Center();
    frame->Show(true);
    return true;
}

int MyApp::OnExit()
{
    FreeConsole();
    return wxApp::OnExit();
}
